/*
 *  uiTexture.cpp
 *  trail-map-editor
 *
 *  Created by Giorgio Tino on 2/19/13.
 *  Copyright 2013 __MyCompanyName__. All rights reserved.
 *
 */

#include "ui.h"

uiTexture::uiTexture(const char* tname, ssgTexture* texture, const float left, const float bottom, const float right, const float top)
{
	this->name = ulStrDup(tname);
    this->texture = texture;
    this->left = left;
    this->bottom = bottom;
    this->right = right;
    this->top = top;
}

uiTexture::~uiTexture()
{
	delete[] name;
    // NOTE : DO NOT delete the texture!
}

void uiTextureList::add(uiTexture *texture)
{
    addEntity(texture);
}

uiTexture* uiTextureList::findByName ( const char* name )
{    
    for ( unsigned int i = 0 ; i < total ; i++ )
    {
        uiTexture* texture = (uiTexture*)entity_list [ i ];
        
        if ( ulStrEqual(texture->name, name) )
            return texture;
    }
    
    return NULL ;
}